home *** CD-ROM | disk | FTP | other *** search
/ SGI Performance Co-Pilot 1.3 / SGI Performance Co-Pilot 1.3.iso / dist / pcp.idb / usr / pcp / lib / pmview-args.z / pmview-args
Text File  |  1997-04-03  |  6KB  |  248 lines

  1. #
  2. #  Copyright (c) 1994 Silicon Graphics, Inc.
  3. #  ALL RIGHTS RESERVED.
  4. #  U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  5. #  Use, duplication or disclosure by the Government is subject to
  6. #  restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph
  7. #  (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
  8. #  at DFARS 252.227-7013 and/or similar or successor clauses in the FAR,
  9. #  or the DOD or NASA FAR Supplement.  Contractor/manufacturer is Silicon
  10. #  Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
  11. #  THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF
  12. #  SILICON GRAPHICS, INC.  ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR
  13. #  DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN
  14. #  PERMISSION OF SILICON GRAPHICS, INC.
  15. # /
  16.  
  17. #
  18. # $Id: pmview-args,v 2.3 1997/03/26 03:21:13 kenmcd Exp $
  19. #
  20.  
  21. prog=`basename $0`
  22.  
  23. #
  24. # Standard usage and command-line argument parsing for pmview front ends.
  25. # This file should be included by pmview front end scripts to present a
  26. # consistent interface. See pmview(1), dkvis(1), mpvis(1) and nfsvis(1)
  27. # for more information on their respective interfaces.
  28. #
  29.  
  30. #
  31. # The front end scripts should call _pmview_usage after their own usage 
  32. # information in a subroutine called _usage. The _usage subroutine may be 
  33. # called by either _pmview_usage or _pmview_args.
  34. #
  35.  
  36. _pmview_usage()
  37. {
  38.     echo '
  39.   -A align      align sample time to natural boundaries
  40.   -a archive    metrics source is an archive log
  41.   -C            check configuration file and exit
  42.   -h host       metrics source is PMCD on host
  43.   -n namespace  use an alternative PMNS
  44.   -O time       initial sample time origin
  45.   -p port       time control port
  46.   -S time       start sample time
  47.   -t interval   sample interval in seconds(float) [default 1.0]
  48.   -T time       terminate sample time
  49.   -z            set reporting timezone to local time for host from -a or -h
  50.   -Z timezone   set reporting timezone
  51.  
  52.   -display  display-string
  53.   -title    title-string
  54.   -geometry geometry-string
  55.   -name     name-string
  56.   -xrm resource [-xrm ..]'
  57. }
  58.  
  59. #
  60. # One of the first actions of a front end script should be to call 
  61. # _pmview_args. It sets the following variables:
  62. #
  63. # host        the host specified with -h.
  64. # arch        the first archive specified with -a (other archives are
  65. #               passed on to pmview).
  66. # args          The list of args that pmview will comprehend and use.
  67. # otherArgs     The arguments pmview will not understand and should be
  68. #               handled by the front end script.
  69. # titleArg    The title the user prefers. If empty, the title should be
  70. #               provided by the front end script.
  71. # prog        The name of the program.
  72. # namespace    The namespace (including the flag) if specified, else empty
  73. #               eg "-n foo"
  74. #
  75.  
  76. _pmview_args()
  77. {
  78.  
  79. host=""
  80. arch=""
  81. args=""
  82. otherArgs=""
  83. titleArg=""
  84. namespace=""
  85.  
  86. while [ $# -gt 0 ]
  87. do
  88.     case $1
  89.     in
  90.     -g*|-d*|-name|-xrm)
  91.         # assume an X11 argument
  92.         if [ $# -lt 2 ]
  93.         then
  94.         echo "$prog: $1 requires one argument"
  95.         _usage
  96.         exit 1
  97.         fi
  98.         args="$args $1 '$2'"
  99.         shift
  100.         ;;
  101.  
  102.     -title)
  103.         # assume an X11 argument
  104.         if [ $# -lt 2 ]
  105.         then
  106.         echo "$prog: $1 requires one argument"
  107.         _usage
  108.         exit 1
  109.         fi
  110.         titleArg="$2"
  111.         shift
  112.         ;;
  113.  
  114.     -A|-D|-O|-p|-S|-T|-t|-Z)
  115.         if [ $# -lt 2 ]
  116.         then
  117.         echo "$prog: $1 requires one argument"
  118.         _usage
  119.         exit 1
  120.         fi
  121.         args="$args $1 '$2'"
  122.         shift
  123.         ;;
  124.  
  125.     -A*|-D*|-O*|-p*|-S*|-T*|-t*|-Z*|-C|-z)
  126.         args="$args $1"
  127.         ;;
  128.  
  129.     -a)
  130.         if [ "X$host" != X ]
  131.         then
  132.         echo "$prog: only one of -h or -a maybe specified"
  133.         _usage
  134.         exit 1
  135.         fi
  136.         if [ $# -lt 2 ]
  137.         then
  138.         echo "$prog: $1 requires one argument"
  139.         _usage
  140.         exit 1
  141.         fi
  142.         if [ "X$arch" = X ]
  143.         then
  144.             arch=$2
  145.         fi
  146.         args="$args -a $2"
  147.         shift
  148.         ;;    
  149.  
  150.     -h)
  151.         if [ "X$arch" != X -o "X$host" != X ]
  152.         then
  153.         echo "$prog: only one of -h or -a maybe specified"
  154.         _usage
  155.         exit 1
  156.         fi
  157.         if [ $# -lt 2 ]
  158.         then
  159.         echo "$prog: $1 requires one argument"
  160.         _usage
  161.         exit 1
  162.         fi
  163.         host=$2
  164.         args="$args -h $2"
  165.         shift
  166.         ;;
  167.  
  168.     -n)
  169.         if [ $# -lt 2 ]
  170.         then
  171.         echo "$prog: $1 requires one argument"
  172.         _usage
  173.         exit 1
  174.         fi
  175.         namespace="-n $2"
  176.         args="$args -n $2"
  177.         shift
  178.         ;;
  179.  
  180.     *)
  181.         otherArgs="$otherArgs $1"
  182.         ;;
  183.  
  184.     esac
  185.     shift
  186. done
  187. }
  188.  
  189. # standard fatal error reporting
  190. # Usage: _pmview_error message goes in here
  191. #        _pmview_error -f file
  192. #
  193. _pmview_error()
  194. {
  195.     _pmview_note Error error $*
  196. }
  197.  
  198. # standard warning
  199. # Usage: _pmview_warning message goes in here
  200. #        _pmview_warning -f file
  201. #
  202. _pmview_warning()
  203. {
  204.     _pmview_note Warning warning $*
  205. }
  206.  
  207. # standard info
  208. # Usage: _pmview_info message goes in here
  209. #        _pmview_info -f file
  210. #
  211. _pmview_info()
  212. {
  213.     _pmview_note Info info $*
  214. }
  215.  
  216. # generic notifier
  217. # Usage: _pmview_note tag icon args ...
  218. #
  219. _pmview_note()
  220. {
  221.     tag=$1; shift
  222.     icon=$1; shift
  223.     button=""
  224.     [ $tag = Error ] && button="-B Quit"
  225.  
  226.     if [ -z "$DISPLAY" -o "${PCP_USE_STDERR+yes}" = yes ]
  227.     then
  228.     if [ $# -eq 2 -a "X$1" = X-f ]
  229.     then
  230.         echo "$prog: $tag: ..."
  231.         cat $2
  232.     else
  233.         echo "$prog: $tag: $*"
  234.     fi
  235.     else
  236.     if [ $# -eq 2 -a "X$1" = X-f ]
  237.     then
  238.         /usr/bin/X11/xconfirm -icon $icon -file $2 -useslider -header "$tag $prog" $button >/dev/null 2>&1
  239.     else
  240.         /usr/bin/X11/xconfirm -icon $icon -t "$*" -noframe -header "$tag $prog" $button >/dev/null 2>&1
  241.     fi
  242.     fi
  243.  
  244.     [ $tag = Error ] && exit 1
  245. }
  246.